package com.souku.finance.application.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.Button;

import com.souku.finance.application.dialog.WaitDialog;

/**
 * Created by Android on 2017/1/6.
 */

public class ButtonWait extends Button {

    private WaitDialog dialog;

    public ButtonWait(Context context) {
        super(context);
    }

    public ButtonWait(Context context, AttributeSet attrs) {
        super(context, attrs);
        dialog= new WaitDialog(context);
    }

    public ButtonWait(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public void setEnabled(boolean enabled) {
        super.setEnabled(enabled);
        if(dialog==null)return;
        if(enabled){
            if(dialog.isShowing()) dialog.dismiss();
        }else {
            if(!dialog.isShowing()) dialog.show();
        }
    }

    public void setEnabledWithText(boolean enabled,String message) {
        super.setEnabled(enabled);
        if(dialog==null)return;
        if(enabled){
            if(dialog.isShowing()) dialog.setfinish(message);
        }else {
            if(!dialog.isShowing()) dialog.show();
        }
    }
}
